<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListCompraTitle}"></h:outputText>
        </ui:define>

        <ui:define name="menuLateral">

            <h:form id="formLateralMenuCompraList">
                <h:panelGroup>
                    <p:slideMenu style="width: 120px">
                        <p:menuitem value="#{bundle.ListCompraCreateLink}" 
                                    action="#{compraController.prepareCreate}" 
                                    icon="ui-icon-plus" />
                        <p:separator />
                        <p:submenu label="Cadastros Obrigatórios" icon="ui-icon-suitcase">
                            <p:submenu label="Pagamentos">
                                <p:menuitem id="menuLateralCondicaoPagamento" 
                                            value="#{bundle.CreateCondicaoPagamentoShowAllLink}"
                                            action="/paginasEntidades/condicaoPagamento/List" ajax="false"/>
                                <p:menuitem id="menuLateralFormaPagamento" 
                                            value="#{bundle.CreateFormaPagamentoShowAllLink}"
                                            action="/paginasEntidades/formaPagamento/List" ajax="false"/>
                            </p:submenu>
                            <p:submenu label="Participantes">
                                <p:menuitem id="menuLateralFornecedor" 
                                            value="#{bundle.CreateFornecedorShowAllLink}"
                                            action="/paginasEntidades/fornecedor/List" ajax="false"/>
                            </p:submenu>
                            <p:submenu label="Produtos">
                                <p:menuitem id="menuLateralProduto" 
                                            value="#{bundle.CreateProdutoShowAllLink}"
                                            action="/paginasEntidades/produto/List" ajax="false"/>
                                <p:menuitem id="menuLateralUnidadeMedida" 
                                            value="#{bundle.CreateUnidadeMedidaShowAllLink}"
                                            action="/paginasEntidades/unidadeMedida/List" ajax="false"/>
                                <p:menuitem id="menuLateralTipoProduto" 
                                            value="#{bundle.CreateTipoProdutoShowAllLink}"
                                            action="/paginasEntidades/tipoProduto/List" ajax="false"/>
                            </p:submenu>
                        </p:submenu>
                    </p:slideMenu>
                </h:panelGroup>
            </h:form>

        </ui:define>
        
        <ui:define name="body">
            <h:form id="formCompraList">
                
                <h:panelGroup id="messagePanel" layout="block">
                    <p:growl/>
                </h:panelGroup>
                
                <h:panelGroup>
                    
                    <p:dataTable id="tableCompra" value="#{compraController.items}" var="item" 
                                 emptyMessage="#{bundle.ListCompraEmpty}" paginator="true" rows="10" 
                                 style="border:solid 1px">
                        
                        <p:column sortBy="#{item.dataCompra}" filterBy="#{item.dataCompra}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCompraTitle_dataCompra}"/>
                            </f:facet>
                            <h:outputText value="#{item.dataCompra}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                            </h:outputText>
                        </p:column>
                        
                        <p:column sortBy="#{item.fornecedor}" filterBy="#{item.fornecedor}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCompraTitle_fornecedor}"/>
                            </f:facet>
                            <h:outputText value="#{item.fornecedor.toString()}"/>
                        </p:column>
                        
                        <p:column style="alignment-baseline: central">
                            <f:facet name="header">
                                <p:commandButton action="#{compraController.prepareCreate}" 
                                                 value="#{bundle.ListCompraCreateLink}" ajax="false"/>
                            </f:facet>
                            <p:commandButton action="#{compraController.prepareView}" value="#{bundle.ListCompraViewLink}" ajax="false"/>
                            <p:commandButton action="#{compraController.prepareEdit}" 
                                             rendered="#{compraController.renderizaEdicaoCompra}"
                                             value="#{bundle.ListCompraEditLink}" ajax="false"/>
                            <p:commandButton action="#{compraController.destroy}" 
                                             rendered="#{compraController.renderizaEdicaoCompra}"
                                             value="#{bundle.ListCompraDestroyLink}" ajax="false"/>
                        </p:column>
                        
                    </p:dataTable>
                </h:panelGroup>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
